package com.aaa.service.xg.impl;

import com.aaa.dao.xg.QuFpaDao;
import com.aaa.pojo.QuFpa;
import com.aaa.service.xg.QuFpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;


import java.util.List;
@Service
public class QuFpaServiceImpl implements QuFpaService {
    @Autowired
    private QuFpaDao qufpaDao;


    @Override
    public List<QuFpa> findAll(String page, String limit) {
        int pageInt = Integer.parseInt(page);
        int limitInt = Integer.parseInt(limit);
        int start = (pageInt - 1) * limitInt;
        List<QuFpa> all = qufpaDao.findAll(start, limitInt);
        return all;
    }

    @Override
    public int findCount() {
        int count = qufpaDao.findCount();
        return count;
    }

    @Override
    public int insert(QuFpa quFpa) {
        int insert = qufpaDao.insert(quFpa);
        return insert;
    }

    @Override
    public int update(QuFpa quFpa) {
        int update = qufpaDao.update(quFpa);
        return update;
    }

    @Override
    public int delete(List<String> idList) {
        if (!CollectionUtils.isEmpty(idList)) {
            int delete = qufpaDao.delete(idList);
            return delete;
        }
        return 0;
    }

    @Override
    public  List<QuFpa> findByQuestionAndName(String question, String createBy,String page,String limit) {
        int parseInt = Integer.parseInt(page);
        int parseInt1 = Integer.parseInt(limit);
        int start = (parseInt - 1)*parseInt1;
        List<QuFpa> byQuestionAndName = qufpaDao.findByQuestionAndName(question, createBy,start,parseInt1);
        return byQuestionAndName;
    }

    @Override
    public int findIfCount(String question, String createBy) {
        int ifCount = qufpaDao.findIfCount(question, createBy);
        return ifCount;
    }

    @Override
    public List<QuFpa> findAllQuestion() {
        List<QuFpa> allQuestion = qufpaDao.findAllQuestion();
        return allQuestion;
    }


}


